package com.formiaomiao.demain.service.impl;

import com.formiaomiao.demain.dao.FriendRemarksDao;
import com.formiaomiao.demain.model.FriendRemarksBean;
import com.formiaomiao.demain.model.Result;
import com.formiaomiao.demain.service.FriendRemarksService;
import com.formiaomiao.demain.utils.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service(value = "friendRemarksService")

public class FriendRemarksServiceImpl implements FriendRemarksService {

    @Autowired
    FriendRemarksDao friendRemarksDao;

    @Override
    public Result<FriendRemarksBean> SelectRemarks(FriendRemarksBean bean) {
        return null;
    }

    @Transactional(value = "demain")
    @Override
    public Result<String> UpdateRemarks(FriendRemarksBean bean) {
        if (friendRemarksDao.SelectRemarks(bean) == null) {
            if(friendRemarksDao.CreateRemarks(bean)==0){
                return ResultUtil.error(400, "修改备注失败");
            } else {
                return ResultUtil.success("修改备注成功");
            }
        }else{
            if(friendRemarksDao.UpdateRemarks(bean)==0){
                return ResultUtil.error(400, "修改备注失败");
            } else {
                return ResultUtil.success("修改备注成功");
            }
        }
    }
}
